import requests

from conmon.get_id_util import get_id
from conmon.token_util import get_token


class ToolsApi:
    # 登录接口
    def req_login(self, req_body):
        self.req_l = requests.post(url="http://ihrm-test.itheima.net/api/sys/login",
                                   headers={"Content-Type": "application/json;charset=UTF-8"},
                                   json=req_body)
        return self.req_l
# 添加员工接口
    def req_add(self, req_body):
        self.req_a = requests.post(url="http://ihrm-test.itheima.net/api/sys/user",
                                   headers={"Content-Type": "application/json;charset=UTF-8",
                                            "Authorization": get_token()},
                                   json=req_body)
        return self.req_a
# 修改员工接口
    def req_modify(self, modify_id, req_body):
        self.req_m = requests.put(url=f"http://ihrm-test.itheima.net/api/sys/user/{modify_id}",
                                headers={"Authorization": get_token()},
                                json=req_body)
        return self.req_m
# 查询接口
    def req_query(self, query_id):
        self.req_q = requests.get(url=f"http://ihrm-test.itheima.net/api/sys/user/{query_id}",
                                  headers={"Authorization": get_token()})

        return self.req_q
    # 删除接口
    def req_delete(self, delete_id):
        self.req_q = requests.delete(url=f"http://ihrm-test.itheima.net/api/sys/user/{delete_id}",
                                  headers={"Authorization": get_token()})

        return self.req_q

